package com.zhss.dfs.backupnode.server;

/**
 * 负责同步editlog的进程
 */
public class BackupNode {

    private volatile Boolean isRunning = true;
    private FSNameSystem nameSystem;
    private NameNodeRpcClient namenode;

    public static void main(String[] args) throws Exception {
        BackupNode backupNode = new BackupNode();
        backupNode.init();
        backupNode.start();

    }

    public void start() throws Exception {
        EditLogFetcher editLogFetcher = new EditLogFetcher(this, nameSystem, namenode);
        editLogFetcher.start();

        FSImageCheckPointer fsImageCheckPointer = new FSImageCheckPointer(this, nameSystem, namenode);
        fsImageCheckPointer.start();

        run();
    }

    public void init() {

        this.nameSystem = new FSNameSystem();
        this.namenode = new NameNodeRpcClient();
    }

    public void run() throws Exception {
        while (isRunning()) {
            Thread.sleep(1000);
        }
    }

    public boolean isRunning() {
        return isRunning;
    }
}
